package com.cl.mybatis.learn.day26.dao;

import com.cl.mybatis.learn.day26.bean.User;
import org.apache.ibatis.jdbc.SQL;

/**
 * 描述该类- JPA
 *
 * @author zhoufei
 * @class: SqlProvider
 * @date 2020/11/26 16:58
 * @Verson 1.0 -2020/11/26 16:58
 * @see
 */
public class SqlProvider {
    
    public String selectAll(final User user) {
        SQL sql = new SQL();
        sql.SELECT("*").FROM("user");
        if (user.getId() != null) {
            sql.WHERE("id=#{id}");
        }
        if (user.getPassword() != null) {
            sql.WHERE("password=#{password}");
        }
        if (user.getUserName() != null) {
            sql.WHERE("user_name=#{userName}");
        }
        return sql.toString();
    }
}